#!/usr/bin/env python3
# -*- coding:utf-8 -*-

# ======================================================
# @File:      : path_utils
# @Author     : forward_huan
# @Date       : 2025/1/5 16:39
# @Desc       :
# ======================================================
from common.utils.path_utils import getRootPath, createDirPath, getCacheDir, pathJoin
from common.utils.time_utils import getTimestamp


def get_root_path():
    """
    获取项目根目录
    :return:
    """
    return getRootPath(level=3)


def get_cache_path(*rel_path, is_dir=True):
    """
    获取缓存相对目录

    :param rel_path: 多个相对路径
    :param is_dir:
    :return:
    """
    path = pathJoin(get_root_path(), "cache", *rel_path)
    createDirPath(path, is_dir=is_dir)
    return path


def get_static_path():
    path = pathJoin(get_root_path(), "upload_file", "html", "static")
    createDirPath(path, is_dir=True)
    return path


def get_template_path():
    path = pathJoin(get_root_path(), "upload_file", "html", "template")
    createDirPath(path, is_dir=True)
    return path


def get_log_path():
    """输出保存log的路径"""
    path = pathJoin(getCacheDir(), "log", getTimestamp(fmt="%Y%m%d") + ".log")
    createDirPath(path, is_dir=False)
    return path


def get_params_path():
    """输出保存参数配置的路径"""
    path = pathJoin(getCacheDir(), "config", "params.conf")
    createDirPath(path, is_dir=False)
    return path


def get_db_path():
    """输出保存参数配置的路径"""
    path = pathJoin(getCacheDir(), "database", "upload_file.db")
    createDirPath(path, is_dir=False)
    return path
